<!DOCTYPE html>
<!--
This is a starter template page. Use this page to start your new project from
scratch. This page gets rid of all links and provides the needed markup only.
-->
<html>
<head>
  <title>角色组管理 - {$sys_config['site_name']}</title>
  {include file="public/head" /}
</head>
<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

  {include file="public/nav" /}
  {include file="public/menu" /}

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        角色组管理
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制台</a></li>
        <li class="active">角色组管理</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content container-fluid">

      <div class="row" >
        <div class="col-xs-12">
          <!-- form start -->
            <form action="{:url('AdminGroup/index')}" class="form-horizontal" style="background: #fff">
              <div class="box-body">
              <div class="row">
                <div class="col-xs-7">
                  <div class="form-group">
                     
                    <div class="col-sm-12">
                      <input type="text" class="form-control" name="name" placeholder="角色组名称">
                    </div>
                  </div>
                </div>
                <div class="col-xs-5">
                  <button type="submit" class="btn btn-info">搜索</button>
                </div>
              </div>
              </div>
            </form> 
            <!-- /.box-header -->
          <div class="box">
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th  style=" width: 200px;">操作</th>
                  <th style=" width: 200px;">角色组ID</th>
                  <th style=" width: 380px;">角色组名称</th>
                  <th style=" width: 200px;">排序</th>
                </tr>
                </thead>
                <tbody>
                
                <tr>
                  <td colspan="100"><small class="btn btn-primary btn-xs open_attr_box" data-id="0"><i class="fa fa-plus"></i> 添加角色组</small></td>
                </tr>
                {foreach name="list" item="vo"}
                <tr>
                  <td>
                    <small class="btn btn-warning btn-xs open_power_box" data-id="{$vo.group_id}"><i class="glyphicon glyphicon-edit"></i> 权限配置</small>
                    <small class="btn btn-primary btn-xs open_attr_box" data-id="{$vo.group_id}"><i class="glyphicon glyphicon-edit"></i> 编辑</small>
                    <small class="btn btn-danger btn-xs del_attr" data-id="{$vo.group_id}"><i class="fa fa-clock-o"></i> 删除</small></td>
                  <td>{$vo.group_id}</td>
                  <td>{$vo.group_name}</td>
                  <td>{$vo.group_sort}</td>
                </tr>
                {/foreach}
                </tbody>
              </table>
              <div class="pull-right">{$page}</div>
            </div>
            <!-- /.box-body -->
           
          </div>
          <!-- /.box -->

        </div>
      </div>
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  {include file="public/foot" /}
</div>
<!-- ./wrapper -->
{include file="public/js" /}
<script type="text/javascript">
//根据需要填写需要的模块
layui.use('layer', function(){
  //弹出添加修改
  $('.open_attr_box').click(function() {
    var group_id = $(this).attr('data-id');
    layer.open({
      type: 2,
      title:'角色组表单',
      btn: ['保存', '取消'],
      area: ['700px', '520px'],
      fixed: false, //不固定
      maxmin: true,
      content: "{:url('AdminGroup/groupForm')}?group_id="+group_id,
      yes: function (index, layero) {
          var iframeWin  = window[layero.find('iframe')[0]['name']];
          var attr_data = iframeWin.confirm();
          $.post("{:url('AdminGroup/saveGroup')}", attr_data,function(res){
              if (res.status==1){
                layer.msg(res.msg,{time:2000},function(index, layero){
                  location.reload();
                });
                return false;
              }else{
                layer.msg(res.msg,{time:2000});
                return false;
              }
         }, "json");
      }
    });
  });
  //删除角色组
  $('.del_attr').click(function () {
     var group_id = $(this).attr('data-id');
     $.post("{:url('AdminGroup/delGroup')}", {group_id:group_id},function(res){
              if (res.status==1){
                layer.msg(res.msg,{time:2000},function(index, layero){
                  location.reload();
                });
                return false;
              }else{
                layer.msg(res.msg,{time:2000});
                return false;
              }
         }, "json");
  });
    //弹出权限配置
    $('.open_power_box').click(function() {
        var group_id = $(this).attr('data-id');
        layer.open({
            type: 2,
            title:'权限配置表单',
            btn: ['保存', '取消'],
            area: ['700px', '520px'],
            fixed: false, //不固定
            maxmin: true,
            content: "{:url('AdminGroup/powerList')}?group_id="+group_id,
            yes: function (index, layero) {
                var iframeWin  = window[layero.find('iframe')[0]['name']];
                var attr_data = iframeWin.confirm();
                $.post("{:url('AdminGroup/powerSave')}", attr_data,function(res){
                    if (res.status==1){
                        layer.msg(res.msg,{time:2000},function(index, layero){
                            location.reload();
                        });
                        return false;
                    }else{
                        layer.msg(res.msg,{time:2000});
                        return false;
                    }
                }, "json");
            }
        });
    });
});
</script>
</body>
</html>